<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body><html lang="en">
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>shopping platform</title>
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
    <link rel="stylesheet" th:href="@{/assets/bootstrap/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/assets/font-awesome/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/assets/css/form-elements.css}">
    <link rel="stylesheet" th:href="@{/assets/css/style.css}">
    <link rel="shortcut icon" th:href="@{/assets/ico/favicon.png}">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" th:href="@{/assets/ico/apple-touch-icon-144-precomposed.png}">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" th:href="@{/assets/ico/apple-touch-icon-114-precomposed.png}">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" th:href="@{/assets/ico/apple-touch-icon-72-precomposed.png}">
    <link rel="apple-touch-icon-precomposed" th:href="@{/assets/ico/apple-touch-icon-57-precomposed.png}">
</head>
<body>
<!-- Top content -->
<div class="top-content">

    <div class="inner-bg">
        <div class="container">
            <div class="row">
                <div class="col-sm-8 col-sm-offset-2 text">
                    <h1><strong>全都要平台</strong> </h1>
                    <div class="description">
                        <p>
                            if you have more <a href="#"><strong>MONEY</strong></a>, you can buy anything you like!
                        </p>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6 col-sm-offset-3 form-box">
                    <div class="form-top">
                        <div class="form-top-left">
                            <h3>欢迎注册</h3>
                            <p>请输入你的基本信息注册：</p>
                        </div>
                        <div class="form-top-right">
                            <i class="fa fa-lock"></i>
                        </div>
                    </div>
                    <div class="form-bottom">
                        <div style="color: orangered;margin-left: 80px" ><p th:text="${msg}"> </p></div>
                        <form role="form" th:action="@{/users/regist}" method="post" class="login-form" onsubmit="return validate_form(this)">
                            <div class="form-group">
                                <label class="sr-only" for="form-username">Username</label>
                                <input type="text" name="username" placeholder="用户名" class="form-username form-control" id="form-username">
                            </div>
                            <div class="form-group">
                                <label class="sr-only" for="form-password">Password</label>
                                <input type="password" name="password" placeholder="密码" class="form-password form-control" id="form-password">
                            </div>
                            <div class="form-group">
                                <label class="sr-only" for="form-password2">Password</label>
                                <input type="password" name="password2" placeholder="再次输入密码" class="form-password form-control" id="form-password2">
                            </div>
                            <div class="form-group">
                                <input type="email" name="email" id="email" placeholder="请输入您的邮箱" class="form-password form-control">
                            </div>
                            <div class="verification">
                                <input type="tel" name="code" id="code" placeholder="请输入验证码" >
                                <a class="btn" id="sendMobileCode" >
                                    <span id="email_btn">获取</span>
                                </a>
                            </div>
                            <button type="submit" class="btn">Sign in!</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

<!-- Javascript -->
<script th:src="@{/assets/js/jquery-1.11.1.js}"></script>
<script th:src="@{/assets/bootstrap/js/bootstrap.min.js}"></script>
<script th:src="@{/assets/js/jquery.backstretch.min.js}"></script>
<script th:src="@{/assets/js/scripts.js}"></script>
<!--[if lt IE 10]>
<script th:src="@{/assets/js/placeholder.js}"></script>
<![endif]-->

<!--邮箱发送验证码-->
<script>
    $("#email_btn").click(function () {
        var email=$("#email").val();
        alert("请打开邮箱认真查找");
        $.ajax({
            type:"POST",
            url:"/users/registerCode",
            data:{"email":email},
            success:function (msg) {
                if(msg["result"]==true){
                    $("#email_tip").text("发送成功");
                }else if(msg["result"] == false){
                    alert("发送失败");
                }
            }
        })
    })
    //表单验证
    //验证邮箱是否为空
    function validate_required(field,alerttxt) {
        with(field){
            if(value==null || value=="")
            {alert(alerttxt);return false}
            else{return true}
        }
    }
    // function validate_email(field,alerttxt){
    //     with(field){
    //         apos = value.indexOf("@")
    //         dotpos=value.lastIndexOf(".")
    //         if(apos<1||dotpos-apos<2)
    //         {alert(alerttxt);return false}
    //         else{return true}
    //     }
    // }

    //验证
    function validate_form(thisform){
        with(thisform){
            if(validate_required(email,"请输入邮箱！！")==false)
            {email.focus();return false}
            if(validate_required(code,"验证码为空！！")==false){
                code.focus();return false
            }
            // if(validate_email(email,"输入的邮箱不正确！")==false)
            // {email.focus();return false}
        }
    }
</script>

</body>
</html>


